import {Urls} from "./ApiUrl";
import {Result, doPostUrlEncoding, doPostJson} from "./generic";

export class LoginReq {
  username: string;
  password: string;

  constructor(username: string, password: string) {
    this.username = username;
    this.password = password;
  }
}

export class RegisterReq {
  username: string;
  password: string;

  constructor(username: string, password: string) {
    this.username = username;
    this.password = password;
  }
}

export const UserApi = {

  Login: (req: LoginReq): Promise<Result<boolean>> => {
    return doPostUrlEncoding(Urls.user.login, req)
  },
  Register: (req: RegisterReq): Promise<Result<boolean>> => {
    return doPostJson(Urls.user.register, req)
  }

}
